package com.example.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestsingleThreadPool {
    public static void main(String[] args) {
        // 单一线程池,永远会维护存在一条线程
        ExecutorService singleThreadPool = Executors.newSingleThreadExecutor();
        for (int i = 0; i < 10; i++) {
            final int j = i;
            singleThreadPool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + ":" + j);
                }
            });
        }
        singleThreadPool.shutdown();
    }
}
